home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / BORL_TIP / TI1000 / TI1762.ASC < prev    next >
Text File  |  1994-01-10  |  4KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Borland Pascal                        NUMBER  :  1762
  9.   VERSION  :  7.0
  10.        OS  :  WIN
  11.      DATE  :  January 10, 1994                         PAGE  :  1/3
  12.  
  13.     TITLE  :  Copying a desktop window into your program's window
  14.  
  15.  
  16.  
  17.  
  18.   {
  19.     The following program shows how to copy the contents of the
  20.     current desktop window into the main window of your program.
  21.   }
  22.  
  23.   {************************************************}
  24.   {  Copy DeskTop Demo program                     }
  25.   {************************************************}
  26.   {
  27.     Here's the beginning of the resource:
  28.     -------------------------------------------------------
  29.     MENU_1 MENU
  30.     BEGIN
  31.           MENUITEM "Blit_Upper_Left_Corner_of_Desktop", 101
  32.     END
  33.     -------------------------------------------------------
  34.     End of Resource (Don't include lines)
  35.   }
  36.   program MyProgram;
  37.  
  38.   uses WinTypes, WinProcs, OWindows;
  39.   {$R BMPDESK}
  40.  
  41.   const
  42.     idBlitIt = 101;
  43.  
  44.   type
  45.     TMyApplication = object(TApplication)
  46.       procedure InitMainWindow; virtual;
  47.     end;
  48.  
  49.   type
  50.     PMyWindow = ^TMyWindow;
  51.     TMyWindow = object(TWindow)
  52.       constructor Init(AParent: PWIndowsObject; Name: PChar);
  53.       destructor Done; virtual;
  54.       procedure BlitIt(var Msg: TMessage);
  55.         virtual Cm_First + idBlitIt;
  56.     end;
  57.  
  58.   {--------------------------------------------------}
  59.   { TMyWindow's method implementations:              }
  60.   {--------------------------------------------------}
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Borland Pascal                        NUMBER  :  1762
  75.   VERSION  :  7.0
  76.        OS  :  WIN
  77.      DATE  :  January 10, 1994                         PAGE  :  2/3
  78.  
  79.     TITLE  :  Copying a desktop window into your program's window
  80.  
  81.  
  82.  
  83.  
  84.   constructor TMyWindow.Init(AParent: PWindowsObject; Name: PChar);
  85.   begin
  86.     inherited Init(AParent, Name);
  87.     Attr.Menu := LoadMenu(HInstance, 'Menu_1');
  88.   end;
  89.  
  90.   destructor TMyWindow.Done;
  91.  
  92.   begin
  93.     inherited Done;
  94.   end;
  95.  
  96.   procedure TMyWindow.BlitIt(var Msg: TMessage);
  97.   var
  98.     DeskDc: HDC;
  99.     TempDC, PaintDC: HDC;
  100.     MyBitMap: HBitMap;
  101.     R: TRect;
  102.   begin
  103.     DeskDc := GetDC(GetDeskTopWindow);
  104.     PaintDC := GetDC(HWindow);
  105.     GetClientRect(HWindow, R);
  106.     BitBlt(PaintDC, 0, 0, R.right, R.bottom, DeskDC, 0, 0,
  107.   SRCCopy);
  108.     ReleaseDC(HWindow, PaintDC);
  109.     ReleaseDC(GetDeskTopWindow, DeskDC);
  110.   end;
  111.  
  112.   {--------------------------------------------------}
  113.   { TMyApplication's method implementations:         }
  114.   {--------------------------------------------------}
  115.  
  116.   procedure TMyApplication.InitMainWindow;
  117.   begin
  118.     MainWindow := New(PMyWindow, Init(nil, 'Sample ObjectWindows
  119.                       Program'));
  120.   end;
  121.  
  122.   {--------------------------------------------------}
  123.   { Main program:                                    }
  124.   {--------------------------------------------------}
  125.  
  126.   var
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Borland Pascal                        NUMBER  :  1762
  141.   VERSION  :  7.0
  142.        OS  :  WIN
  143.      DATE  :  January 10, 1994                         PAGE  :  3/3
  144.  
  145.     TITLE  :  Copying a desktop window into your program's window
  146.  
  147.  
  148.  
  149.  
  150.     MyApp: TMyApplication;
  151.  
  152.   begin
  153.     MyApp.Init('MyProgram');
  154.     MyApp.Run;
  155.     MyApp.Done;
  156.   end.
  157.  
  158.   DISCLAIMER: You have the right to use this technical information
  159.   subject to the terms of the No-Nonsense License Statement that
  160.   you received with the Borland product to which this information
  161.   pertains.
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.